<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>是否领用电脑</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />
    <script th:src="@{/layui/layui.js}"></script>
    <script th:src="@{/js/register/jquery-3.1.0.min.js}"></script>
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item" style="margin-top: 25px">
        <input type="hidden" name="studid" th:value="${student.studid}">
        <input type="hidden" name="stuname" th:value="${student.stuname}">
        <label class="layui-form-label">是否领用电脑</label>
        <div class="layui-input-inline">
            <select name="collar">
                <option value="是" th:selected="${'是'==student.collar}">是</option>
                <option value="否" th:selected="${'否'==student.collar}">否</option>
            </select>

        </div>
    </div>
    <div class="layui-form-item" style="margin-left: 275px">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>

        </div>
    </div>
</form>

</body>
<script type="text/javascript" th:inline="none">

    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        //你可以在这里做操作  也可以不使用这个方法
        form.on('submit(formDemo)', function(data){
            $.ajax({
                url: '/stu/upd',
                type: 'post',
                data:data.field,
                dataType: 'json',
                success:function(data){
                    if(data){
                        layer.msg(JSON.stringify("成功"));
                        //先得到当前iframe层的索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //再执行关闭
                        parent.layer.close(index);
                        window.parent.location.reload();
                    }else {
                        alert("你以毕业");
                        //先得到当前iframe层的索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //再执行关闭
                        parent.layer.close(index);
                        window.parent.location.reload();
                    }
                },
            })
            //$('.layui-laypage-btn').click();//刷新
            return false;
        });
    });
</script>
</html>